package com.bobi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bobi.entity.Goods;
import com.bobi.pojo.condition.Condition;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface GoodsMapper extends BaseMapper<Goods> {
    @Select("<script>" +
            "SELECT id, goods_name AS goodsName, quantity, category_id, goods_img AS goodsImg, price, market_enable AS marketEnable, create_by AS createBy, create_time AS createTime " +
            "FROM bobi_goods " +
            "WHERE 1=1 " +
            "<if test='condition.goodsName != null'>AND goods_name LIKE CONCAT('%', #{condition.goodsName}, '%')</if> " +
            "<if test='condition.createBy != null'>AND create_by = #{condition.createBy}</if> " +
            "<if test='condition.createTime != null'>AND create_time = #{condition.createTime}</if> " +
            "<if test='condition.categoryId != null'>AND category_id = #{condition.categoryId}</if> " +
            "</script>")
    List<Goods> getGoods(@Param("condition") Condition condition);
    @Select("<script>SELECT * FROM bobi_goods</script>")
    List<Goods> getAllGoods();

}
